package com.help.help.util;

import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.excel.EasyExcel;
import com.help.help.entity.AddressEntity;
import com.sun.deploy.net.URLEncoder;
import org.apache.poi.ss.formula.functions.T;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class ExceUtil {
    /**
     *
     * @param filename    文件名
     * @param response  响应对象
     */
             public static void out(String filename, HttpServletResponse response){

         try {
             filename =   URLEncoder.encode(filename,"utf-8");
         } catch (UnsupportedEncodingException e) {
             System.out.println("字符串异常");
         }
        //response为HttpServletResponse对象
         response.setContentType("application/vnd.ms-excel;charset=utf-8");
        //test.xls是弹出下载对话框的文件名，不能为中文，中文请自行编码
         response.setHeader("Content-Disposition","attachment;filename="+filename+".xlsx");
     }
}
